﻿using System.Web;
using System.Web.Mvc;
using SilenthinkCommon.Components;

namespace SilenthinkCommon.Helpers
{
    public class SkUrlHelper
    {
        private static string scriptTagTpl;
        private static string styleTagTpl;
        private readonly UrlHelper helper;
        public SkUrlHelper(UrlHelper helper)
        {
            this.helper = helper;
            scriptTagTpl = "<script type=\"text/javascript\" src=\"{0}/{1}.js\" ></script>";
            styleTagTpl = "<link type=\"text/css\" href=\"{0}/{1}.css\" rel=\"stylesheet\" />";
        }

        public IHtmlString StaticJs(string fileName)
        {
            const string folder = "js/";
            var val = string.Format(scriptTagTpl, WebSite.Static, folder + fileName);
            return new MvcHtmlString(val);
        }

        public IHtmlString StaticCss(string fileName)
        {
            const string folder = "css/";
            var val = string.Format(styleTagTpl, WebSite.Static, folder + fileName);
            return new MvcHtmlString(val);
        }
        public IHtmlString DynamicJs(string domain, string fileName)
        {
            var val = string.Format(scriptTagTpl, domain, fileName);
            return new MvcHtmlString(val);
        }
        
    }
}